#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

#define FOR(i,a,n) for(int i=a,_n(n);i<_n;++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

bool IsLucky(const string& s)
{
    REP(i,s.size()) if(s[i]!='4'&&s[i]!='7') return false;
    int sum1 = 0, sum2 = 0;
    REP(i,s.size()/2) sum1 += s[i]-'0', sum2 += s[i+s.size()/2] - '0';
    if(sum1 != sum2) return false;
    return true;
}

int main()
{
    int n;
    string s;
    while(cin>>n>>s)
    {
        if(IsLucky(s)) puts("YES");
        else puts("NO");
    }
	return 0;
}
